package com.dy.service;

import com.dy.entity.Order;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Service;

import java.io.IOException;

/**
 * @Auther: dy
 * @Date: 2022/4/19 - 04 - 19 - 20:33
 * @Description: com.dy.service
 * @version: 1.0
 */
@Service
public class QueueService {
    @Autowired
    private IFeignCinemaService feignCinemaService;

    @RabbitListener(queues = "dyDeadQueue")
    public void getDeadQueue(Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag, Order order) throws IOException {
        System.out.println("Ribbon Test");
        //处理业务
        feignCinemaService.getOrder(order);
        //手动ack
        channel.basicAck(tag,false); //tag 通道的标志，false 不批量确认
    }
}
